package leecode

func findAnagramsLCR(s string, p string) (result []int) {
	if len(p) > len(s) {
		return
	}
	sArr, pArr := [26]uint{}, [26]uint{}
	for i := 0; i < len(p); i++ {
		pArr[p[i]-'a']++
		sArr[s[i]-'a']++ //初始化窗口
	}
	if sArr == pArr {
		result = append(result, 0)
	}
	for right := len(p); right < len(s); right++ {
		//窗口不停右移,寻找正确结果
		sArr[s[right]-'a']++
		sArr[s[right-len(p)]-'a']--
		if sArr == pArr {
			result = append(result, right-len(p)+1)
		}
	}
	return
}
